00001 // 00002 // Copyright (c) 2013 Battelle Memorial Institute 00003 // Licensed under modified BSD License. A copy of this license can be found 00004 // in the LICENSE file in the top level directory of this distribution. 00005 // 00006 // Emacs Mode Line: -*- Mode:c++;-*- 00007 // ------------------------------------------------------------- 00008 /** 00009 * @file named.h 00010 * @author William A. Perkins 00011 * @date 2017-02-10 07:31:37 d3g096 00012 * 00013 * @brief 00014 * 00015 * 00016 */ 00017 // ------------------------------------------------------------- 00018 // ------------------------------------------------------------- 00019 // Battelle Memorial Institute 00020 // Pacific Northwest Laboratory 00021 // ------------------------------------------------------------- 00022 // ------------------------------------------------------------- 00023 // Created March 25, 2013 by William A. Perkins 00024 // Last Change: Thu Jun 3 06:45:08 2010 by William A. Perkins <d3g096@PE10900.pnl.gov> 00025 // ------------------------------------------------------------- 00026 00027 // SCCS ID: $Id$ Battelle PNL 00028 00029 #ifndef _named_h_ 00030 #define _named_h_ 00031 00032 #include <string> 00033 00034 #include <boost/serialization/string.hpp> 00035 #include <boost/serialization/export.hpp> 00036 00037 namespace gridpack { 00038 namespace utility { 00039 00040 // ------------------------------------------------------------- 00041 // class Named 00042 // ------------------------------------------------------------- 00043 class Named { 00044 public: 00045 00046 /// Default constructor. 00047 Named(void) 00048 : p_name() 00049 {} 00050 00051 /// Construct with a value 00052 Named(const std::string& s) 00053 : p_name(s) 00054 {} 00055 00056 /// Construct with a C-string 00057 Named(const char *s) 00058 : p_name(s) 00059 {} 00060 00061 /// Protected copy constructor to avoid unwanted copies. 00062 Named(const Named& old) 00063 : p_name(old.p_name) 00064 {} 00065 00066 /// Destructor 00067 virtual ~Named(void) {} 00068 00069 /// Get this instance's name 00070 virtual std::string name(void) const 00071 { 00072 return p_name; 00073 } 00074 00075 /// Set this instance's name 00076 void name(const std::string& s) 00077 { 00078 p_name = s; 00079 } 00080 00081 protected: 00082 00083 /// The name of this instance 00084 std::string p_name; 00085 00086 private: 00087 00088 friend class boost::serialization::access; 00089 00090 template<class Archive> 00091 void serialize(Archive &ar, const unsigned int) 00092 { 00093 ar & p_name; 00094 } 00095 }; 00096 00097 } // namespace utility 00098 } // namespace gridpack 00099 00100 BOOST_CLASS_EXPORT_KEY(gridpack::utility::Named) 00101 00102 #endif